home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
update.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
17KB
|
633 lines
/*
* EKED-M1 : Editor for Korg M1 synth; update.c : parameter updating
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <string.h>
#include <gemfast.h>
#include "gm/gem_man.h"
#include "eked-m1.h"
#include "defs.h"
#include "types.h"
#include "externs.h"
static void snum3_update(OBJECT *object, int value);
static void bit_update(OBJECT *object, int value);
static void tri_update(OBJECT *object, int value);
static void oct_update(OBJECT *object, int value);
static void omod_update(OBJECT *object, int value);
static void amod_update(OBJECT *object, int value);
static void note_update(OBJECT *object, int value);
static void key_update(OBJECT *object, int value);
static void msnd_update(OBJECT *object, int value);
static void dsnd_update(OBJECT *object, int value);
static void rev_update(OBJECT *object, int value);
static void ert_update(OBJECT *object, int value);
static void del_update(OBJECT *object, int value);
static void sped_update(OBJECT *object, int value);
static void bal_update(OBJECT *object, int value);
static void pan_update(OBJECT *object, int value);
static void lfc_update(OBJECT *object, int value);
static void hfc_update(OBJECT *object, int value);
static void twav_update(OBJECT *object, int value);
static void rout_update(OBJECT *object, int value);
static void vel_update(OBJECT *object, int value);
static void dis_update(OBJECT *object, int value);
static void chan_update(OBJECT *object, int value);
static void cpan_update(OBJECT *object, int value);
static void pol_update(OBJECT *object, int value);
static void ped_update(OBJECT *object, int value);
static void scal_update(OBJECT *object, int value);
typedef struct {
int min; /* minimum value */
int max; /* maximum value */
UPDATE_FUNC_PTR update; /* update function */
} PARA_ATRB;
PARA_ATRB atrb_table[] = {
{0, 99, &unum_update}, /* UNUM */
{0, 3, &unum1_update}, /* UN3 */
{-99, 99, &snum_update}, /* SNUM */
{-12, 12, &snum_update}, /* SN12 */
{-50, 50, &snum_update}, /* SN50 */
{0, 99, &msnd_update}, /* MSND */
{-1, 1, &oct_update}, /* OCT */
{0, 127, ¬e_update}, /* NOTE */
{0, 2, &omod_update}, /* OMOD */
{0, 1, &pol_update}, /* POL */
{0, 9, &ped_update}, /* PED */
{0, 4, &scal_update}, /* SCAL */
{0, 11, &key_update}, /* KEY */
{0, 44, &dsnd_update}, /* DSND */
{12, 115, ¬e_update}, /* DKEY */
{-120,120, &snum3_update}, /* S120 */
{1, 127, &vel_update}, /* VEL */
{0, 97, &rev_update}, /* REV1 */
{0, 47, &rev_update}, /* REV2 */
{0, 70, &ert_update}, /* ERT1 */
{0, 30, &ert_update}, /* ERT2 */
{0, 9, &unum1_update}, /* UN9 */
{-10, 10, &snum_update}, /* SN10 */
{0, 100, &bal_update}, /* BAL */
{0, 101, &pan_update}, /* PAN */
{0, 2, &lfc_update}, /* LFC */
{0, 2, &hfc_update}, /* HFC */
{0, 50, &del_update}, /* DEL1 */
{0, 150, &del_update}, /* DEL2 */
{0, 200, &del_update}, /* DEL3 */
{0, 216, &sped_update} /* SPED */
};
void para_edit(int handle, OBJECT *tree, int ob,
PARA_TYPE t, int page, int pos, BYTE *data)
{
int new, old, d;
char *s;
switch(t){
case UNUM: case UN3: case SNUM: case SN12:
case SN50: case MSND: case OCT: case NOTE:
case OMOD: case POL: case PED: case SCAL:
case KEY: case DSND: case DKEY: case S120:
case VEL:
case REV1: case REV2: case ERT1: case ERT2:
case UN9: case SN10: case BAL: case PAN:
case LFC: case HFC: case DEL1:
case DEL2: case DEL3: case SPED:
old = (t >= DEL2) ? ((UBYTE) *data) : *data;
new = wm_roll(handle, tree, ob, old, atrb_table[t].min, atrb_table[t].max,
atrb_table[t].update);
if(new != old){
*data = new;
tx_para_chg(page, pos, new);
}
break;
case PROG:
old = (data[10] & 0x10) ? -1 : (data[0] & 0xFF);
new = wm_roll(handle, tree, ob, old, -1, 199, &prog_update);
if(new != old){
if(new == -1)
data[10] |= 0x10;
else{
data[10] &= ~0x10;
data[0] = new;
}
tx_para_chg(page, pos, new + 1);
}
break;
case WAVE:
old = EXTRACT_2LO(*data);
new = wm_roll(handle, tree, ob, old, 0, 3, &wave_update);
if(new != old){
*data = REPLACE_2LO(*data, new);
tx_para_chg(page, pos, new);
}
break;
case AMOD:
old = EXTRACT_BIT(*data, 0);
new = wm_roll(handle, tree, ob, old, 0, 1, &amod_update);
if(new != old){
*data = REPLACE_BIT(*data, 0, new);
tx_para_chg(page, pos, new);
}
break;
case BIT0: case BIT1: case BIT2: case BIT3:
case BIT4: case BIT5: case BIT6: case BIT7:
t -= BIT0;
d = *data;
old = EXTRACT_BIT(d, t);
new = wm_roll(handle, tree, ob, old, 0, 1, &bit_update);
if(new != old){
*data = REPLACE_BIT(d, t, new);
if(t == 5 || t == 6) /* modulation bits have to be changed together */
tx_para_chg(page, pos, EXTRACT_56(*data));
else
tx_para_chg(page, pos, new);
}
break;
case TRI0: case TRI1: case TRI2: case TRI3:
t -= TRI0;
d = *data;
old = EXTRACT_BIT(d, t) ? (EXTRACT_BIT(d, t + 4) ? -1 : 1) : 0;
new = wm_roll(handle, tree, ob, old, -1, 1, &tri_update);
if(new != old){
d = REPLACE_BIT(d, t, new != 0);
*data = REPLACE_BIT(d, t + 4, new < 0);
tx_para_chg(page, pos, new + 1);
}
break;
case NM10:
tree[ob].ob_state |= SELECTED;
wm_ob_update(handle, tree, ob);
s = TEXT_PTR(name_form, NM_NAME);
(void) korg2str(s, data, (size_t) 10);
d = fm_dialog(name_form, NM_NAME, tree, ob);
if(d == NM_OK){
(void) str2korg(data, s, (size_t) 10);
(void) strfcpy(TEXT_PTR(tree, ob), s, (size_t) 10);
}
tree[ob].ob_state &= ~SELECTED;
wm_ob_update(handle, tree, ob);
break;
case TWAV:
d = *data;
old = EXTRACT_BIT(d, 0);
new = wm_roll(handle, tree, ob, old, 0, 1, &twav_update);
if(new != old){
*data = REPLACE_BIT(d, 0, new);
tx_para_chg(page, pos, new);
}
break;
case DEL4:
old = ((UBYTE) (data[0])) + (((UBYTE) (data[1])) << 8);
new = wm_roll(handle, tree, ob, old, 0, 500, &del_update);
if(new != old){
data[0] = new;
data[1] = new >> 8;
tx_para_chg(page, pos, new);
}
break;
case ROUT:
d = *data;
old = EXTRACT_BIT(d, 4);
new = wm_roll(handle, tree, ob, old, 0, 1, &rout_update);
if(new != old){
*data = REPLACE_BIT(d, 4, new);
tx_para_chg(page, pos, new);
}
break;
case DIS0: case DIS1: case DIS2: case DIS3:
t -= DIS0;
d = *data;
old = EXTRACT_BIT(d, t);
new = wm_roll(handle, tree, ob, old, 0, 1, &dis_update);
if(new != old){
*data = REPLACE_BIT(d, t, new);
tx_para_chg(page, pos, new);
}
break;
case CHAN:
d = *data;
old = EXTRACT_NYBLE(d);
new = wm_roll(handle, tree, ob, old, 0, 15, &chan_update);
if(new != old){
*data = REPLACE_NYBLE(d, new);
tx_para_chg(page, pos, new);
}
break;
case CPAN:
d = *data;
old = EXTRACT_NYBLE(d);
new = wm_roll(handle, tree, ob, old, 0, 13, &cpan_update);
if(new != old){
*data = REPLACE_NYBLE(d, new);
tx_para_chg(page, pos, new);
}